//
//  main.swift
//  PlayData
//
//  Created by 冯琰琰 on 2022/3/18.
//

import Foundation

print("Hello, World!")



func mySqrt(_ x: Int) -> Int {
    var left = 1
    var right = x
    var ans = 0
    while left <= right {
        let mid = left + (right - left)/2
        if mid * mid <= x {
            left = mid + 1
            ans = mid
        } else {
            right = mid - 1
        }
        
    }
    return ans
}
mySqrt(8)
